﻿#This is a R script to generate the probabality distribution function. We adopted the normal distribution function i.e. Gaussian function 
#to fit he histogram we acquired. We use P value of K-S test as the indication of HOW the real distribution obey the normal distribution.

setwd("D:/PaperRev2/PDF/")
rt<-read.table("core02.dat", header=FALSE)
nh<-log10(rt[[3]])-21  #x-axis is set as log scale.

hist(
nh,
seq(-2,2,0.2),
freq=FALSE,
xlab="Column Density/"
)

lines(density(nh,bw=0.2),col="blue",lwd=2)
x<-seq(-1.2,1.2,0.01)
lines(x,dnorm(x,mean(nh),sd(nh)),col="red",lwd=2)
rug(nh)